package pers.jsan.litheopen.openserver.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import pers.jsan.litheopen.security.cache.RedisUserManager;
import pers.jsan.litheopen.security.config.LitheAuthenticationConfig;
import pers.jsan.litheopen.security.oauth.service.IUserDetailService;
import pers.jsan.litheopen.security.prover.AuthenticationManager;
import pers.jsan.litheopen.security.prover.LitheAuthenticationProver;

@Configuration
public class AuthConfig extends LitheAuthenticationConfig {

    @Autowired
    private LitheAuthenticationProver litheAuthenticationProver;

    @Autowired
    private IUserDetailService userDetailService;

    @Autowired
    private RedisUserManager redisUserManager;

    public AuthenticationManager initConfigure() {
        return new AuthenticationManager()
                //登录认证
                .setAuthenticationProver(litheAuthenticationProver
                        .setUserDetailService(userDetailService))
                .setCacheUserManager(redisUserManager)
                .setWebPath("http://localhost:9000")
                //停用客户端校验拦截器
                .setClientOnlineDisable(true);
    }
}
